<?php


namespace Admin\Controller;

use Think\Cache\Driver\Memcache;
use Think\Cache\Driver\Redis;

class LeavewordController extends AdminController
{


    public function area_demo()
    {
//        423,500,505
        $area = D('Area')->getArea();

        $this->assign('area_json', json_encode($area));
        $this->display();
    }

    public function ajax_area()
    {
        $post = I();
        $area = D('Area')->getArea($post['parentid']);

        return $this->ajaxReturn($area);
    }


    public function save(){
        dump($_POST);
    }

    public function add(){
        $this->display();
    }
    public function redis(){
        //Redis缓存第一种方法
        $redis = new Redis();
        $redis->connect('',6379);
        $redis->set('test','hello!');
        dump($redis->get("test"));

        //Redis缓存第二种方法
        S(array(
            'type'=>'Redis',
            'host'=>'192.168.0.172',
            'port'=>'6379',
            'prefix'=>'redis',
            'expire'=>60));
        S('s',"adsadasd");
        $a = S('s');
        dump($a);

        $this->display();
    }
    public function memcache(){
        //1.memcache缓存第一种方法
        $mem = new Memcache();
        $mem->connect('',11211);
        $mem->set('test','hello!');
        dump($mem->get("test"));

        //2.memcache缓存第二种方法
        S(array(
            'type'=>'memcache',
            'host'=>'192.168.0.172',
            'port'=>'11211',
            'prefix'=>'memcache',
            'expire'=>60));
        S('hh',"htllow");
        $a = S('hh');
        dump($a);
    }
    public function clear(){
        $redis = new Redis();
//        $redis->rm();
        $redis->clear();
    }
}